function x = vec(X)
% a = [1 2;3 4] => vec(a) = [1 3 2 4]';
% vec(a') = [1 2 3 4]'

x = X(:);

%[m n] = size(X);
%x = reshape(X,m*n,1);